/*
 * Copyright © 2010 Breachwalls & Company Inc. and other authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.breachwalls.h2p.platform.core.schema;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.breachwalls.eap.schema.DefaultSchemaContext;
import com.breachwalls.eap.schema.GenerateMode;
import com.breachwalls.eap.schema.SchemaGenerator;
import com.breachwalls.eap.schema.SchemaGeneratorException;
import com.breachwalls.eap.schema.hibernate.HibernateDialect;
import com.breachwalls.eap.schema.hibernate.HibernateSchemaGenerator;

/**
 * スキーマジェネレータの実行クラス.
 * @author Ken Todoroki
 * @version $Revision: 244 $
 */
public final class SchemaGeneratorExecutor {

    private static final String BASE_PACKAGE = "com.breachwalls.diagnosis.persistence.entity";

    private static Logger logger = LoggerFactory.getLogger(SchemaGeneratorExecutor.class);

    private SchemaGeneratorExecutor() {
    }

    public static void main(String[] args) {
        DefaultSchemaContext context = new DefaultSchemaContext();
        context.setDialect(HibernateDialect.MYSQL);
        context.setGenerateMode(GenerateMode.CREATE_DROP);
        context.setEntityPackage(BASE_PACKAGE);
        context.setOutputFileName("ddl_gen_" + HibernateDialect.MYSQL.name().toLowerCase() + ".sql");

        try {
            SchemaGenerator generator = new HibernateSchemaGenerator();
            generator.generate(context);
        } catch (SchemaGeneratorException e) {
            logger.error("スキーマの自動生成に失敗しました。", e);
        }
    }

}
